<template>
    <div>
      <Row class="search-info-style">
        <Col span="6">
          <span>类别：</span>
          <Select v-model="searchInfo.category" style="width:200px">
            <Option value="">全部</Option>
            <Option value="1" >工作服务类</Option>
            <Option value="2" >评比表彰类</Option>
            <Option value="3" >创建示范类</Option>
            <Option value="4" >标识类</Option>
            <Option value="0" >其他</Option>
          </Select>
        </Col>
        <Col span="6">
            <span>级别：</span>
            <Select v-model="searchInfo.level" style="width:200px">
              <Option value="">全部</Option>
              <Option value="1">市级</Option>
              <Option value="2">区县</Option>
              <Option value="3">街道</Option>
            </Select>
          </Col>
          <Col span="6">
            <span>位置：</span>
            <Select v-model="searchInfo.room" style="width:200px">
              <Option value="">全部</Option>
              <Option value="0">室内</Option>
              <Option value="1">室外</Option>
            </Select>
          </Col>
          <Col span="2" style="float:right" pull="1">
              <Button class="new-btn-sty" @click="findtime()"><Icon type="ios-search" /> 搜索</Button>
            </Col>
      </Row>
      <Table border :columns="columns1" :data="datalist" ></Table>
      <Row v-if="loadData == true">
        <Col class="demo-spin-col" span="8" offset="8">
          <Spin fix>
            <Icon type="ios-loading" size=18 class="demo-spin-icon-load"></Icon>
            <div>数据正在加载</div>
          </Spin>
        </Col>
      </Row>
      <Page class="page_style" :total="searchInfo.totalnum" :current="searchInfo.currentPageNo"
              :page-size="searchInfo.currentPageSize" @on-change="changePageNo" show-total  show-sizer @on-page-size-change="size"/>
      <Modal v-model="modalEdit" title="详细信息" width="700" cancel-text="关闭"
        @on-ok="ok111(paramData2)" @on-cancel="modalEdit=false" ok-text="确定">
        <Form :model="paramData2" >
          <Row class="item1">
            <Col span="5" style="text-align: right" class="">挂牌机构:</Col>
            <Col span="12" offset="1">
              <Input v-model="paramData2.community_name" disabled></Input>
            </Col>
          </Row>
          <Row class="item1" style="height:auto;line-height:auto">
            <Col span="5" style="text-align: right" class="">牌子名称:</Col>
            <Col span="12" offset="1">
              <Input v-model="paramData2.brand_name" disabled></Input>
            </Col>
          </Row>
          <Row class="item1" style="height:auto;line-height:auto">
            <Col span="5" style="text-align: right" class="">创建机构:</Col>
            <Col span="12" offset="1">
              <Input v-model="paramData2.create_name" disabled></Input>
            </Col>
          </Row>
          <Row class="item1">
            <Col span="5" style="text-align: right" class="">牌子类别:</Col>
            <Col span="12" offset="1">
            <!-- 1.工作服务类/2.评比表彰类/3.创建示范类/0.其他 -->
                <Select v-model="paramData2.category" disabled>
                  <Option value="0">其他</Option>
                  <Option value="1">工作服务类</Option>
                  <Option value="2">评比表彰类</Option>
                  <Option value="3">创建示范类</Option>
                  <Option value="4" >标识类</Option>
                </Select>
              </Col>
          </Row>
          <Row class="item1">
            <Col span="5" style="text-align: right" class="">位置:</Col>
            <Col span="12" offset="1">
                <Select v-model="paramData2.room" disabled>
                  <Option value="0">室内</Option>
                  <Option value="1">室外</Option>
                </Select>
              </Col>
          </Row>
          <Row class="item1">
            <Col span="5" style="text-align: right" class="">牌子级别:</Col>
            <Col span="12" offset="1">
                <Select v-model="paramData2.level" disabled>
                  <Option value="1">市级</Option>
                  <Option value="2">区/县</Option>
                  <Option value="3">街道</Option>
                </Select>
              </Col>
          </Row>
          <Row  class="item1">
            <Col span="5" style="text-align: right" class="">审批时间:</Col>
            <Col span="12" offset="1">
              <DatePicker type="datetime" format="yyyy-MM-dd HH:mm" v-model="paramData2.create_time" placeholder="代理时间" style="width: 100%" disabled></DatePicker>
            </Col>
          </Row>
        </Form>
      </Modal>
    </div>
</template>
<script>
import { findListingList, date0str } from '@/api/eventlist'
export default {
  data () {
    return {
      searchInfo: {
        applyname: '',
        order_code: '',
        applytime: [],
        totalnum: 0,
        currentPageNo: 1,
        currentPageSize: 10,
        department_name: ''
      },
      paramData2: {},
      modalEdit: false,
      loadData: true,
      param: {},
      datalist: [],
      columns1: [
        { title: '序号', type: 'index', key: 'index', width: 100, align: 'center' },
        { title: '机构名称', key: 'company_code_name', width: 200, align: 'center', sortable: true },
        { title: '牌子名称', key: 'brand_name', width: 200, align: 'center', sortable: true },
        { title: '颁发时间', key: 'create_time', width: 200, align: 'center', sortable: true },
        { title: '状态', key: 'approval_name', width: 200, align: 'center', sortable: true },
        { title: '位置', key: 'room_name', width: 200, align: 'center', sortable: true },
        { title: '级别', key: 'level_name', width: 200, align: 'center', sortable: true },
        {
          title: '操作',
          key: 'action',
          align: 'center',
          className: 'nopadding',
          minWidth: 150,
          render: (h, params) => {
            let temp = []
            temp.push(
              h('Button', {
                props: { type: 'primary', size: 'small' },
                style: { marginRight: '5px', backgroundColor: '#598ED1', borderColor: '#598ED1' },
                on: {
                  click: () => {
                    this.editNotice(params.row)
                  }
                }
              }, '详情')
            )
            return h('div', temp)
          }
        }
      ]
    }
  },
  methods: {
    init (param) {
      param.pageNo = this.searchInfo.currentPageNo
      param.pageSize = this.searchInfo.currentPageSize
      findListingList(param).then(res => {
        console.log(res.data.errcode)
        if (res.data.errcode === 0) {
          this.datalist = res.data.data.results
          this.searchInfo.totalnum = res.data.data.totalRecord
          this.datalist.forEach(function (item1, index) {
            if (item1.room === '0') {
              item1.room_name = '室内'
            } else if (item1.room === '1') {
              item1.room_name = '室外'
            }
            if (item1.subsidiary_name) {
              item1.brand_name = item1.subsidiary_name
            }
          })
          this.loadData = false
        } else {
          this.loadData = true
          this.$Notice.error({ title: '获取发起列表失败', desc: res.data.errmsg })
        }
      })
    },
    size (pageSize) {
      this.searchInfo.currentPageSize = pageSize
      this.changePageNo()
    },
    changePageNo (pageNo) {
      console.log(pageNo)
      this.searchInfo.currentPageNo = pageNo
      let params = {
        name: this.searchInfo.applyname
        // state: this.tabInfoAll.list[this.tabInfoAll.tabIndex].state
      }
      this.init(params)
    },
    findtime () {
      this.param.level = this.searchInfo.level
      this.param.category = this.searchInfo.category
      this.param.room = this.searchInfo.room
      this.init(this.param)
    },
    editNotice (item) {
      this.modalEdit = true
      let create_time = new Date()
      if (item.create_time) {
        create_time = date0str(item.create_time)
      }
      this.paramData2.create_time = create_time
      this.paramData2.community_name = item.company_code_name
      this.paramData2.brand_name = item.brand_name
      this.paramData2.create_name = item.create_by_name
      this.paramData2.room = item.room
      this.paramData2.category = item.category
      this.paramData2.level = item.level
    }
  },
  mounted () {
    this.init(this.param)
  }
}
</script>
<style>
  .page_style {
    margin-top: 10px;
    text-align: right;
  }
  .search-info-style {
    margin: 10px;
  }
  .item1{
    height: 42px;
    line-height: 40px;
  }
  .new-btn-sty {
    margin-right: 5px;
    color: #fff;
    background-color: #235CA7;
    border-color: #235CA7;
    font-weight: 500;
  }
</style>
